home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / miscpas.zip / GRAPHICS.DOC < prev    next >
Text File  |  1987-10-04  |  14KB  |  330 lines

  1.  
  2.  
  3.               SURPAS-86 SUPPLEMENTARY DOCUMENTATION
  4.                      IBM PC Graphics Driver
  5.  
  6.                        Copyright (C) 1987
  7.                         Tixaku Pty Ltd           
  8.  
  9.  
  10.  
  11. On  your SURPAS distribution disk you will find two files  called 
  12. GRAPHICS.PAS  and  GRAPHICS.BIN.  They contain a complete set  of 
  13. graphic drivers for the IBM Color/Graphics Adapter and enable you 
  14. to use medium and high resolution graphics in your SURPAS  Pascal 
  15. programs.  The  graphic drivers support all three graphic  modes: 
  16. 320 x 200 color graphics, 320 x 200 monochrome graphics and 620 x 
  17. 200  monochrome graphics.  If your system is not equipped with  a 
  18. Color/Graphics Adapter you cannot use the graphic drivers.
  19.  
  20. To include the graphic drivers in a program,  place the following 
  21. compiler directive at the very beginning of the program:
  22.  
  23.     (*$I GRAPHICS*)
  24.  
  25. This will include the file called GRAPHICS.PAS in the compilation 
  26. of your source text.  Alternatively you can copy the entire GRAP-
  27. HICS.PAS file into your source text. GRAPHICS.PAS contains a list 
  28. of very short procedures,  each of which calls an EXTERNAL proce-
  29. dure called GRAPHICS. The code for the GRAPHICS procedure is read 
  30. from  the  GRAPHICS.BIN file and it contains the actual  drivers. 
  31. The  drivers  are written in machine code to  optimize  execution 
  32. speed.
  33.  
  34. The  following procedures and functions are provided by the  gra-
  35. phic driver package:
  36.  
  37.     CRTMODE             Set CRT mode.
  38.     WINDOW              Define Window Coordinates.
  39.     BCOLOR              Set Background Color.
  40.     PCOLOR              Set Color Palette.
  41.     FCOLOR              Set Foreground Color.
  42.     COLORMAP            Define Color Map.
  43.     FILLSCREEN          Fill Screen.
  44.     MOVETO              Set Current Position.
  45.     MOVEBY              Set Current Position Relative.
  46.     LINETO              Draw Line.
  47.     LINEBY              Draw Line Relative.
  48.     PLOTAT              Plot Point.
  49.     PLOTBY              Plot Point Relative.
  50.     PAINT               Paint Area.
  51.     POINT               Read Color Of Dot.
  52.  
  53. Each routine is described in detail below.
  54.  
  55. All  graphic  routines operate within a window.  By  default  the 
  56. window is set to the entire graphic image,  i.e.  (0,0)-(319,199) 
  57. for  medium resolution and (0,0)-(639,199) for  high  resolution, 
  58. but  there are occations when it is handy to use only part of the 
  59. screen, while safeguarding the rest from accidental use. For this 
  60. purpose, the graphic drivers allow you to define any rectangle on 
  61. the screen as the window.
  62.  
  63. The graphic routines operate on integer  coordinates.  Thus,  the 
  64. coordinate  range is -32768..32767.  However,  coodinates outside 
  65. the  window are ignored.  When a line is drawn using any  of  the 
  66. graphic  routines,  it is automatically clipped so that only  the 
  67. portion which lies within the current window is displayed. Points 
  68. whose  coordinates are not within the current window,  even those 
  69. points  that  would not be on the screen at all,  are  legal  but 
  70. ignored.
  71.  
  72. It is possible to mix text and graphics on the screen.  In 320  x 
  73. 200  graphics mode the screen can display 40 x 25 characters  and 
  74. in 640 x 200 graphics mode it can display 80 x 25 characters.  To 
  75. write a text on the graphics screen,  use the GOTOXY procedure or 
  76. an  Escape-Y sequence to move the cursor (which is not visible in 
  77. graphics  mode) to the relevant row/column,  and output the  text 
  78. using a WRITE statement. Each character cell occupies 8 x 8 dots, 
  79. so the actual X coordinate of the upper left corner of a  charac-
  80. ter  cell is the row number times 8,  and the actual Y coordinate 
  81. is the column number times 8.  Note that the foreground color set 
  82. by  FCOLOR  does not apply when text is written to  the  graphics 
  83. screen.  The  foreground  color of text is  selected  through  an 
  84. Escape-b sequence.  For further details on this,  please refer to 
  85. the  IBMPC.DOC Supplementary Documentation file on your distribu-
  86. tion disk.
  87.  
  88.  
  89. Function:   Set CRT Mode.
  90.  
  91. Header:     PROCEDURE CRTMODE(M: INTEGER);
  92.  
  93. Remarks:    This procedure is used to set the CRT operating mode. 
  94.             M  is  an integer between 0 and 7  which  selects  an 
  95.             operating mode according to the table below:
  96.         
  97.             0 = 40 x 25 Black and White.
  98.             1 = 40 x 25 Color.
  99.             2 = 80 x 25 Black and White.
  100.             3 = 80 x 25 Color.
  101.             4 = 320 x 200 Color Graphics.
  102.             5 = 320 x 200 Monochrome Graphics.
  103.             6 = 640 x 200 Monochrome Graphics.
  104.             7 = 80 x 25 Black and White (Monochrome Display).
  105.  
  106.             Mode  7 should only be selected if your IBM PC or  XT 
  107.             is  equipped with a Monochrome Display Adapter.  When 
  108.             CRTMODE is called,  the window is reset to the  whole 
  109.             screen,  the  current position becomes (0,0) and  the 
  110.             foreground  color becomes 3 (CRT modes 4 and 5) or  1 
  111.             (CRT  mode 6).  All of the routines described in  the 
  112.             following operate correctly in modes 4-6 only.
  113.  
  114.  
  115. Function:   Define Window Coordinates.
  116.  
  117. Header:     PROCEDURE WINDOW(X1,Y1,X2,Y2: INTEGER);
  118.  
  119. Remarks:    The  window  is  the area on the screen that  may  be 
  120.             manipulated by the graphic routines.  By default  the 
  121.             window is the whole screen,  but through this command 
  122.             the  boundaries of the window may be changed.  Every-
  123.             thing outside the window remains unchanged during all 
  124.             graphic operations until it again becomes part of the 
  125.             window.  (X1,Y1) and (X2,Y2) are the opposite corners 
  126.             of  the window (no special ordering is  required).  X 
  127.             coordinates  must be between 0 and 319 (CRT  modes  4 
  128.             and  5) or 639 (CRT mode 6) and Y coordinates must be 
  129.             between 0 and 199.  If one or more of the coordinates 
  130.             are  out of range,  the window is  not  changed.  The 
  131.             current position becomes the upper left corner of the 
  132.             window.  Note  that CRTMODE resets the window to  the 
  133.             entire screen.
  134.  
  135.  
  136. Function:   Set Background Color.
  137.  
  138. Header:     PROCEDURE BCOLOR(C: INTEGER);
  139.  
  140. Remarks:    For  320  x  200 graphics (CRT modes 4  and  5)  this 
  141.             procedure  sets the background color.  For 640 x  200 
  142.             graphics  (CRT mode 6) it sets the color value of the 
  143.             foreground  color  (the background  color  is  always 
  144.             black in this mode).  C is an integer between 0 to 15 
  145.             which selects a color according to the table below:
  146.  
  147.             0 = Black.                  8 = Dark Gray.
  148.             1 = Blue.                   9 = Light Blue.
  149.             2 = Green.                 10 = Light Green.
  150.             3 = Cyan.                  11 = Light Cyan.
  151.             4 = Red.                   12 = Light Red.
  152.             5 = Magenta.               13 = Light Magenta.
  153.             6 = Brown.                 14 = Yellow.
  154.             7 = Light Gray.            15 = White.
  155.  
  156.             For 320 x 200 graphics, the background color defaults 
  157.             to  black (0).  For 640 x 200 graphics it defaults to 
  158.             white  (15),  since  it is  actually  the  foreground 
  159.             color.
  160.  
  161.  
  162. Function:   Set Color Palette.
  163.  
  164. Header:     PROCEDURE PCOLOR(C: INTEGER);
  165.  
  166. Remarks:    This  procedure  has meaning only for 320 x 200  gra-
  167.             phics (CRT modes 4 and 5).  C is an integer between 0 
  168.             and  1  which selects the  foreground  color  palette 
  169.             according to the table below:
  170.  
  171.             0 = Green, Red and Yellow foreground colors.
  172.             1 = Cyan, Magenta and White foreground colors.
  173.  
  174.             The default palette is 1. The screen can only display 
  175.             the colors of one palette.  Thus,  all foreground co-
  176.             lors  on  the  screen change instantly  when  an  new 
  177.             palette is selected.
  178.  
  179.  
  180. Function:   Set Foreground Color.
  181.  
  182. Header:     PROCEDURE FCOLOR(C: INTEGER);
  183.  
  184. Remarks:    C is an integer between -1 and 3 (320 x 200 graphics) 
  185.             or  -1  and 1 (640 x 200 graphics).  It  selects  the 
  186.             foreground color, i.e. the color to be used for lines 
  187.             and  dots  drawn by the LINETO,  LINEBY,  PLOTAT  and 
  188.             PLOTBY routines.  For 320 x 200 graphics, C selects a 
  189.             foreground color according to the table below:
  190.  
  191.             -1 = Use color map set by COLORMAP.
  192.              0 = Background color set by BCOLOR.
  193.              1 = Green (palette 0) or Cyan (palette 1).
  194.              2 = Red (palette 0) or Magenta (palette 1).
  195.              3 = Yellow (palette 0) or White (palette 1).
  196.  
  197.             For 640 x 200 graphics,  C selects a foreground color 
  198.             according to the table below:
  199.  
  200.             -1 = Use color map set by COLORMAP.
  201.              0 = Black.
  202.              1 = Color set by BCOLOR.
  203.  
  204.             For  details on color mapping (foreground color  -1), 
  205.             see  the description of the COLORMAP  procedure.  The 
  206.             default foreground color is 3 for 320 x 200  graphics 
  207.             and  1  for 640 x 200 graphics.  Note that the  fore-
  208.             ground  color set by FCOLOR does not apply when  text 
  209.             is written to the graphics screen through write  sta-
  210.             tements (use Escape-b instead).
  211.  
  212.  
  213. Function:   Define Color Map.
  214.  
  215. Header:     PROCEDURE COLORMAP(C0,C1,C2,C3: INTEGER);
  216.  
  217. Remarks:    When the foreground color (set by FCOLOR) is -1,  the 
  218.             graphic routines use a color map to write dots on the 
  219.             screen.  Essentially  the color map is a  translation 
  220.             table: When a dot is written, its current color value 
  221.             is  used to determine its new value.  C0 defines  the 
  222.             new  color that dots of color 0 should have when they 
  223.             are  written,  C1 defines the new color for color  1, 
  224.             etc.  For instance, if the color map is (3,2,1,0) and 
  225.             the foreground color is -1,  LINETO,  LINEBY,  PLOTAT 
  226.             and  PLOTBY will complement dots when they are  writ-
  227.             ten.  A color map of (0,2,2,2) will turn dots of  all 
  228.             foreground  colors  into color 2,  but it will  leave 
  229.             dots of the background color unchanged.  In 640 x 200 
  230.             graphics mode the screen can only show two colors  (0 
  231.             and 1),  so C2 and C3 are ignored in this mode. There 
  232.             is no default color map;  the COLORMAP procedure must 
  233.             be called before foreground color -1 is used.
  234.  
  235.  
  236. Function:   Fill Screen.
  237.  
  238. Header:     PROCEDURE FILLSCREEN(C: INTEGER);
  239.  
  240. Remarks:    FILLSCREEN  fills  the entire window with  the  color 
  241.             specified by C. C is an integer between -1 and 3 (320 
  242.             x 200 graphics) or -1 and 1 (640 x 200 graphics). For 
  243.             a definition of the colors associated with the values 
  244.             of C please refer to the description of FCOLOR.  When 
  245.             C is -1,  FILLSCREEN uses the color map.  This allows 
  246.             some dramatic effects.  For example, if the color map 
  247.             is  (3,2,1,0),  FILLSCREEN(-1) makes a "negative"  of 
  248.             the  contents  of  the window.  If the color  map  is 
  249.             (0,1,0,3),  FILLSCREEN  will turn all red or  magenta 
  250.             dots into the background color.
  251.  
  252.  
  253. Function:   Set Current Position.
  254.  
  255. Header:     PROCEDURE MOVETO(X,Y: INTEGER);
  256.  
  257. Remarks:    The current position becomes (X,Y).
  258.  
  259.  
  260. Function:   Set Current Position Relative.
  261.  
  262. Header:     PROCEDURE MOVEBY(DX,DY: INTEGER);
  263.  
  264. Remarks:    (DX,DY) is added to the current position.
  265.  
  266.  
  267. Function:   Draw Line.
  268.  
  269. Header:     PROCEDURE LINETO(X,Y: INTEGER);
  270.  
  271. Remarks:    Draws a line in the current foreground color from the 
  272.             current position to (X,Y).  The current position then 
  273.             becomes (X,Y).
  274.  
  275.  
  276. Function:   Draw Line Relative.
  277.  
  278. Header:     PROCEDURE LINEBY(DX,DY: INTEGER);
  279.  
  280. Remarks:    Draws a line in the current foreground color from the 
  281.             current   position  to  the  current  position   plus 
  282.             (DX,DY).  (DX,DY) is then added to the current  posi-
  283.             tion.
  284.  
  285.  
  286. Function:   Plot Point.
  287.  
  288. Header:     PROCEDURE PLOTAT(X,Y: INTEGER);
  289.  
  290. Remarks:    Plots  a  point  in the current foreground  color  at 
  291.             (X,Y). The current position becomes (X,Y).
  292.  
  293.  
  294. Function:   Plot Point Relative.
  295.  
  296. Header:     PROCEDURE PLOTBY(DX,DY: INTEGER);
  297.  
  298. Remarks:    Plots a point in the current foreground color at  the 
  299.             current position plus (DX,DY).  (DX,DY) is then added 
  300.             to the current position.
  301.  
  302.  
  303. Function:   Paint Area.
  304.  
  305. Header:     PROCEDURE PAINT(X,Y,FC,BC: INTEGER);
  306.  
  307. Remarks:    Fills  in an area on the screen with the color speci-
  308.             fied  by  FC.  (X,Y) are the coordinates of  a  point 
  309.             within  the area to be painted.  BC is  the  boundary 
  310.             color, i.e. the color of the edges of the area. PAINT 
  311.             has  no effect if the starting point already has  the 
  312.             boundary  color.  If  the shape to be painted is  not 
  313.             closed, the foreground color will "leak out" and fill 
  314.             the entire window. On the other hand, if the shape is 
  315.             closed  but the starting point is outside  it,  PAINT 
  316.             will  fill the surrounding area.  PAINT never  paints 
  317.             beyond  the current window.  FC and BC must  be  true 
  318.             colors,  i.e.  0-3 for 320 x 200 graphics and 0-1 for 
  319.             640 x 200 graphics. Color mapping is not supported by 
  320.             PAINT.
  321.  
  322.  
  323. Function:   Return Color Of Dot.
  324.  
  325. Header:     FUNCTION POINT(X,Y: INTEGER): INTEGER;
  326.  
  327. Remarks:    Returns the color of the dot at (X,Y),  i.e.  0-3 for 
  328.             320 x 200 graphics and 0-1 for 640 x 200 graphics. If 
  329.             (X,Y) is outside the window, POINT returns -1.
  330.